<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>考勤</title>
    
    <link href="css/mui.min.css" rel="stylesheet"/>
    <link href="css/style.css" rel="stylesheet"/>
    <link href="css/iconfont.css" rel="stylesheet"/>
    <script src="js/mui.min.js"></script>
</head>
<body>
<script>
	//模拟登陆状态，实际使用删除
//	window.localStorage.setItem('id', "1");
//	window.localStorage.setItem('name', "马云");
//	window.localStorage.setItem('phone', "18722530981");
//	window.localStorage.setItem('position', "1");
	
	mui.init();
	window.localStorage.setItem('root', "http://192.168.191.1:8080/att");

	//初始化，并预加载webview模式的选项卡			
	function preload () {
		mui.preload({
			id:'dash.html',
			url:'templates/dash.html',
			styles: {
				popGesture: 'hide'
			}
		});
	}
	
	//首页返回键处理
	//处理逻辑：1秒内，连续两次按返回键，则退出应用；
	var first = null;
	mui.back = function() {
		//首次按键，提示‘再按一次退出应用’
		if (!first) {
			first = new Date().getTime();
			mui.toast('再按一次退出应用');
			setTimeout(function() {
				first = null;
			}, 1000);
		} else {
			if (new Date().getTime() - first < 1000) {
				plus.runtime.quit();
			}
		}
	};
	
	mui.plusReady(function() {
		if(window.localStorage.getItem('id') == null){
			mui.openWindow({
				url:'templates/login.html',
				id:'login.html',
				createNew:false,
			});
		}else{
			//延迟的原因：优先打开启动导航页面，避免资源争夺
			setTimeout(function () {
				//预加载
				preload();
			},200);

			mui.openWindow({
				url:'templates/dash.html',
				id:'dash.html',
				createNew:false,
			});
		}
	});
</script>
</body>
</html>